import socket, time

# 建立UDP的连接
mysocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# 飞秋的通信端口默认是2425
mysocket.connect(('localhost', 2425))

# IPMSG的报文格式：版本号:包编号:发送者姓名:发送者主机名:命令字:附加信息
packetID = str(time.time())
name = 'zeng'
host = 'mycomputer'
command = str(0x00000020)
content = 'This is msg from Python'
msg = 'a.txt.0:' + packetID + ':' + name + ':' + host + ':' + command + ':' + content

# 发送数据包并关闭连接
mysocket.send(msg.encode('GBK'))
mysocket.close()
